-module(autotest).
-export([run_auto_test/0]).

run_auto_test()->
    {ok, FileId} = file:open("auto_test_log.txt",[write]),
    lists:foreach(fun(X)->run_test(FileId, X) end, get_test_list()),
    file:close(FileId).


get_test_list()->
    [
     %test name, path to data
     {"Test 1",
      get_default_node_list(),
      get_default_count_process(),
      "../tst/mooser10.txt",
      "../result/mooser10."}
%     {"Test 2", ""},
%     {"Test 3", ""},
%     {"Test 4", ""}
%     {"Test },
%     {},
%     {},
%     {},
%     {},
%     {}
    ].

get_default_node_list()->
    [slave1@bluestar, slave2@bluestar].

get_default_count_process()->
    1.

run_test(Log,
	 {TestName,
	  Nodes,
	  Process,
	  File,
	  Result})->
	{Hour, Min, Sec} = get_time(),
    io:fwrite(Log, "Start test ~s time: ~w:~w:~w ~n", [TestName, Hour, Min, Sec]),
    {ok, FileId} = file:open(Result, [write]),
    Graph = io_graph:load_graph({text, File}),
    {LHour, LMin, LSec} = get_time(),
    io:fwrite(Log, "End Load graph/start time: ~w:~w:~w ~n",[LHour, LMin, LSec]),
    master:start_master(Nodes,
			Process,
			Graph,
			FileId),
     {SHour, SMin, SSec} = get_time(),
    io:fwrite(Log, "End test ~s time: ~w:~w:~w ~n", [TestName, SHour, SMin, SSec]).
			
get_time()->
    time().
